const mergeList = (arr1: any[], arr2: any[]) => {
  // 对2个待合并的数组进行快速排序
  arr1.sort((a, b) => a.XH - b.XH);
  arr2.sort((a, b) => a.XH - b.XH);

  const result = [];
  let i = 0, j = 0, pre = '';

  // 双指针扫描两个有序数组，并将其合并到 result 数组中
  while (i < arr1.length || j < arr2.length) {
    let index = '';
    if (i >= arr1.length || +arr1[i].GUID > +arr2[j].GUID) {
      index = arr2[j].GUID;
      j++;
    } else {
      index = arr1[i].GUID;
      i++;
    }
    if (index !== pre) {
      pre = index;
      result.push(index);
    }
  }
  return result;
}

export default mergeList;
